<template>
  <view class="container">
    <!-- 滚动视图容器 -->
    <scroll-view 
      class="scroll-view" 
      scroll-y 
      enhanced 
      show-scrollbar="false"
    >
      <!-- 顶部轮播图 -->
      <view class="swiper-container">
        <swiper 
          class="swiper" 
          autoplay 
          interval="3000" 
          duration="500" 
          indicator-dots 
          indicator-color="rgba(255,255,255,0.5)"
          indicator-active-color="#ffffff"
        >
      <swiper-item>
        <image 
          src="/static/city1.png" 
          class="swiper-img" 
          mode="widthFix"
          alt="城市风景图片1"
        ></image>
      </swiper-item>
      <swiper-item>
        <image 
          src="/static/city2.jpg" 
          class="swiper-img" 
          mode="widthFix"
          alt="城市风景图片2"
        ></image>
      </swiper-item>
      <swiper-item>
        <image 
          src="/static/city3.jpg" 
          class="swiper-img" 
          mode="widthFix"
          alt="城市风景图片3"
        ></image>
      </swiper-item>
        </swiper>
      </view>

      <!-- 内容区域 -->
      <view class="content">
        <!-- 城市介绍 -->
        <view class="section">
          <view class="section-title">城市介绍</view>
          <rich-text class="city-intro" :nodes="cityIntro"></rich-text>
        </view>

        <!-- 探索进度 -->
        <view class="section">
          <view class="section-title">探索进度</view>
          <view class="progress-container">
            <progress 
              :percent="exploreProgress" 
              stroke-width="6" 
              activeColor="#36D" 
              backgroundColor="#eee"
            ></progress>
            <view class="progress-text">{{ exploreProgress }}%</view>
          </view>
        </view>

        <!-- 城市选择 -->
        <view class="section">
          <view class="section-title">城市选择</view>
          <view class="picker-container">
            <picker 
              mode="multiSelector" 
              :range="cityData" 
              :value="selectedCityIndex" 
              @change="onCityChange"
              class="city-picker"
            >
              <view class="picker-view">
                {{ selectedProvince }} - {{ selectedCity }} - {{ selectedDistrict }}
                <uni-icons type="arrowright" size="16" color="#999"></uni-icons>
              </view>
            </picker>
          </view>
        </view>

        <!-- 偏好设置 -->
        <view class="section">
          <view class="section-title">偏好设置</view>
          
          <!-- 出行方式选择 -->
          <view class="preference-item">
            <view class="preference-label">出行方式</view>
            <radio-group class="radio-group" v-model="travelMode">
              <label class="radio-label" v-for="(mode, index) in travelModes" :key="index">
                <radio :value="mode.value" color="#36D"></radio>
                <text>{{ mode.label }}</text>
              </label>
            </radio-group>
          </view>
          
          <!-- 推荐景点开关 -->
          <view class="preference-item">
            <view class="preference-label">显示推荐景点</view>
            <switch 
              v-model="showRecommend" 
              color="#36D"
              @change="onRecommendChange"
            ></switch>
          </view>
          
          <!-- 探索半径设置 -->
          <view class="preference-item">
            <view class="preference-label">探索半径: {{ exploreRadius }}km</view>
            <slider 
              v-model="exploreRadius" 
              min="1" 
              max="50" 
              step="1" 
              activeColor="#36D"
              @change="onRadiusChange"
            ></slider>
          </view>
        </view>

        <!-- 媒体展示 -->
        <view class="section">
          <view class="section-title">城市宣传</view>
          <view class="video-container">
			 <video 
			   class="city-video"
			   :src="videoUrl" 
			   controls 
			   poster="/static/city1.png"
			   title="城市宣传视频"
			 ></video>
          </view>
        </view>
      </view>
    </scroll-view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      // 轮播图数据已在模板中直接使用
      
      // 城市介绍富文本数据
      cityIntro: [
        {
          name: 'p',
          attrs: {
            style: 'margin-bottom: 10px;'
          },
          children: [
            {
              type: 'text',
              text: '这座城市拥有'
            },
            {
              name: 'span',
              attrs: {
                style: 'font-weight: bold; color: #36D;'
              },
              children: [
                {
                  type: 'text',
                  text: '千年历史文化'
                }
              ]
            },
            {
              type: 'text',
              text: '与现代都市风貌的完美融合。'
            }
          ]
        },
        {
          name: 'p',
          attrs: {
            style: 'margin-bottom: 10px;'
          },
          children: [
            {
              type: 'text',
              text: '这里既有古色古香的传统建筑，也有高耸入云的摩天大楼，是探索历史与未来的理想之地。'
            }
          ]
        },
        {
          name: 'p',
          children: [
            {
              type: 'text',
              text: '每年吸引数百万游客前来体验其独特的魅力与风情。'
            }
          ]
        }
      ],
      
      // 探索进度
      exploreProgress: 60,
      
      // 城市选择数据
      cityData: [
        ['北京市', '上海市', '广东省'],
        ['北京市', '上海市', '广州市', '深圳市'],
        ['东城区', '西城区', '朝阳区', '海淀区', '丰台区']
      ],
      selectedCityIndex: [0, 0, 0],
      selectedProvince: '北京市',
      selectedCity: '北京市',
      selectedDistrict: '东城区',
      
      // 偏好设置数据
      travelModes: [
        { label: '公交', value: 'bus' },
        { label: '自驾', value: 'drive' },
        { label: '步行', value: 'walk' }
      ],
      travelMode: 'bus',
      showRecommend: true,
      exploreRadius: 10,
      
      // 视频地址
      videoUrl: '/static/city-video.mp4'
    };
  },
  methods: {
    // 城市选择变化
    onCityChange(e) {
      const val = e.detail.value;
      this.selectedCityIndex = val;
      this.selectedProvince = this.cityData[0][val[0]];
      this.selectedCity = this.cityData[1][val[1]];
      this.selectedDistrict = this.cityData[2][val[2]];
    },
    
    // 推荐景点开关变化
    onRecommendChange(e) {
      this.showRecommend = e.detail.value;
      // 可以在这里添加相应的逻辑处理
    },
    
    // 探索半径变化
    onRadiusChange(e) {
      this.exploreRadius = e.detail.value;
      // 可以在这里添加相应的逻辑处理
    }
  }
};
</script>

<style scoped>
.container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: #f5f5f5;
}

.scroll-view {
  flex: 1;
  height: 100%;
}

/* 轮播图样式 */
.swiper-container {
  width: 100%;
}

.swiper {
  width: 100%;
  height: 300rpx;
}

.swiper-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 内容区域样式 */
.content {
  padding: 20rpx;
}

.section {
  background-color: #ffffff;
  border-radius: 16rpx;
  padding: 30rpx;
  margin-bottom: 20rpx;
  box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
}

.section-title {
  font-size: 32rpx;
  font-weight: bold;
  color: #333333;
  margin-bottom: 20rpx;
  padding-bottom: 15rpx;
  border-bottom: 1rpx solid #eeeeee;
}

/* 城市介绍样式 */
.city-intro {
  font-size: 28rpx;
  color: #666666;
  line-height: 1.6;
}

/* 进度条样式 */
.progress-container {
  display: flex;
  flex-direction: column;
  gap: 15rpx;
}

.progress-text {
  align-self: flex-end;
  font-size: 28rpx;
  color: #36D;
  font-weight: bold;
}

/* 城市选择器样式 */
.picker-container {
  width: 100%;
}

.city-picker {
  width: 100%;
}

.picker-view {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20rpx;
  background-color: #f9f9f9;
  border-radius: 8rpx;
  font-size: 28rpx;
  color: #333333;
}

/* 偏好设置样式 */
.preference-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20rpx 0;
  border-bottom: 1rpx solid #eeeeee;
}

.preference-item:last-child {
  border-bottom: none;
}

.preference-label {
  font-size: 28rpx;
  color: #333333;
}

.radio-group {
  display: flex;
  gap: 30rpx;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 5rpx;
  font-size: 28rpx;
  color: #666666;
}

/* 视频容器样式 */
.video-container {
  width: 100%;
  border-radius: 8rpx;
  overflow: hidden;
  background-color: #000000;
}

.city-video {
  width: 100%;
  height: 400rpx;
}
</style>
